package com.xmmxjy.system.service.impl;

import com.xmmxjy.common.service.impl.BaseServiceImpl;
import com.xmmxjy.common.util.Tools;
import com.xmmxjy.system.dao.DictDataDao;
import com.xmmxjy.system.dao.DictTypeDao;
import com.xmmxjy.system.entity.DictDataEntity;
import com.xmmxjy.system.entity.DictTypeEntity;
import com.xmmxjy.system.page.DictPage;
import com.xmmxjy.system.service.DictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 描述：角色
 * @author: xmm
 * @since：2016年09月19日 16时37分13秒 星期一 
 * @version:1.0
 */

@Service("dictTypeService")
public class DictTypeServiceImpl extends BaseServiceImpl<DictTypeEntity> implements DictTypeService {
	@Autowired
	private DictTypeDao dictTypeDao;
	@Autowired
	private DictDataDao dictDataDao;
	@Override
	public List<DictPage> findAllDict() {
		List<DictPage> dictList = new ArrayList<DictPage>();
		List<DictTypeEntity> typeEntityList = dictTypeDao.selectAll();
		if (Tools.isListEmpty(typeEntityList)) {
			return null;
		}
		for (DictTypeEntity dictTypeEntity : typeEntityList) {
			List<DictDataEntity> dataEntityList = dictDataDao.selectByCode(dictTypeEntity.getCode());
			DictPage page = new DictPage();
			page.setTypeEntity(dictTypeEntity);
			page.setDataEntityList(dataEntityList);
			dictList.add(page);
		}
		return dictList;
	}
}
